Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@phc/format
Advanced tools
📝 PHC string format serializer/deserializer
Coded with ❤️ by Simone Primarosa.
The PHC String Format is an attempt to specify a common hash string format that’s a restricted & well defined subset of the Modular Crypt Format. New hashes are strongly encouraged to adhere to the PHC specification, rather than the much looser Modular Crypt Format.
npm install --save @phc/format
const phc = require('@phc/format');
const phcobj = {
id: 'pbkdf2-sha256',
params: {i: 6400},
salt: Buffer.from('0ZrzXitFSGltTQnBWOsdAw', 'base64'),
hash: Buffer.from('Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M', 'base64'),
};
const phcstr = "$pbkdf2-sha256$i=6400$0ZrzXitFSGltTQnBWOsdAw$Y11AchqV4b0sUisdZd0Xr97KWoymNE0LNNrnEgY4H9M";
phc.serialize(phcobj);
// => phcstr
phc.deserialize(phcstr);
// => phcobj
You can also pass an optional version parameter.
const phc = require('@phc/format');
const phcobj = {
id: 'argon2i',
version: 19,
params: {
m: 120,
t: 5000,
p: 2
},
salt: Buffer.from('iHSDPHzUhPzK7rCcJgOFfg', 'base64'),
hash: Buffer.from('J4moa2MM0/6uf3HbY2Tf5Fux8JIBTwIhmhxGRbsY14qhTltQt+Vw3b7tcJNEbk8ium8AQfZeD4tabCnNqfkD1g', 'base64'),
};
const phcstr = "$argon2i$v=19$m=120,t=5000,p=2$iHSDPHzUhPzK7rCcJgOFfg$J4moa2MM0/6uf3HbY2Tf5Fux8JIBTwIhmhxGRbsY14qhTltQt+Vw3b7tcJNEbk8ium8AQfZeD4tabCnNqfkD1g";
phc.serialize(phcobj);
// => phcstr
phc.deserialize(phcstr);
// => phcobj
string
Generates a PHC string using the data provided.
Object
Parses data from a PHC string.
string
Generates a PHC string using the data provided.
Kind: global function
Returns: string
- The hash string adhering to the PHC format.
Param | Type | Description |
---|---|---|
opts | Object | Object that holds the data needed to generate the PHC string. |
opts.id | string | Symbolic name for the function. |
[opts.version] | Number | The version of the function. |
[opts.params] | Object | Parameters of the function. |
[opts.salt] | Buffer | The salt as a binary buffer. |
[opts.hash] | Buffer | The hash as a binary buffer. |
Object
Parses data from a PHC string.
Kind: global function
Returns: Object
- The object containing the data parsed from the PHC string.
Param | Type | Description |
---|---|---|
phcstr | string | A PHC string to parse. |
Contributions are REALLY welcome and if you find a security flaw in this code, PLEASE report it.
Please check the contributing guidelines for more details. Thanks!
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the license file for details.
FAQs
PHC string format serializer/deserializer
The npm package @phc/format receives a total of 255,580 weekly downloads. As such, @phc/format popularity was classified as popular.
We found that @phc/format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.